import axios from 'axios';
import { UserStore } from './Store/UserStore';
import Cookies from 'js-cookie';


const serviceform = axios.create({
    baseURL:'/api',
    timeout: 10000,
    headers:{
        'Content-Type': 'application/x-www-form-urlencoded',//或者'application/json' 根据不同情况而定
    }
})

// 请求拦截器
serviceform.interceptors.request.use(
    (config) => {
      const token = Cookies.get('token') // 从存储中获取令牌
      if (token) {
        config.headers['Authorization'] = `${token}`;
      }
      return config;
    },
    (error) => {
      return Promise.reject(error);
    }
  );

export default serviceform
